import { http } from '@/utils/http'
import { baseURLApi } from '../utils'

export type PageResult<T> = {
  total: number
  list: Array<T>
}
export type ArticleVO = {
  id: number
  title: string
  category: string
  summary: string
  author: string
  tags: Array<string>
  cover: string
  isTop: number
  createTime: Date
}
export type ArticlePage = {
  pageSize: number
  currentPage: number
  title?: string
  tagId?: number
  categoryId?: number
}

export const getArticlePage = (data: ArticlePage) => {
  return http.request<PageResult<ArticleVO>>('get', baseURLApi('/article'), { params: data })
}

export const getArticleDetail = (id: number) => {
  return http.request<any>('get', baseURLApi(`/article/${id}`))
}
